home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / distri~1 / updates / incobj30.zoo / level30.zoo / usr / include / falcon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-10  |  11.6 KB  |  357 lines

  1. /*
  2.  * GNU-C Bindings for Falcon XBIOS functions
  3.  * -- hyc 11-9-92 (uunet!hanauma.Jpl.Nasa.Gov!hyc)
  4.  */
  5.  
  6. #ifndef _FALCON_H
  7. #define _FALCON_H
  8.  
  9. #ifndef _OSBIND_H
  10. #include <osbind.h>
  11. #endif
  12.  
  13. #ifndef trap_14_wwwwww
  14. #define trap_14_wwwwww(n,a,b,c,d,e)                    \
  15. ({                                    \
  16.     register long retvalue __asm__("d0");                \
  17.     short _a = (short)(a);                        \
  18.     short _b = (short)(b);                        \
  19.     short _c = (short)(c);                        \
  20.     short _d = (short)(d);                        \
  21.     short _e = (short)(e);                        \
  22.                                     \
  23.     __asm__ volatile                        \
  24.     ("\
  25.         movw    %4,sp@-; \
  26.         movw    %3,sp@-; \
  27.         movw    %2,sp@-; \
  28.         movw    %1,sp@-; \
  29.         movw    %0,sp@- "                    \
  30.     :: "r"(_a), "r"(_b), "r"(_c), "r"(_d), "r"(_e));        \
  31.                                     \
  32.     __asm__ volatile                        \
  33.     ("\
  34.         movw    %1,sp@-; \
  35.         trap    #14; \
  36.         lea    sp@(12),sp"                    \
  37.     : "=r"(retvalue)                        \
  38.     : "g"(n)                            \
  39.     : "d0", "d1", "d2", "a0", "a1", "a2");                \
  40.     retvalue;                            \
  41. })
  42. #endif
  43.  
  44. /*
  45.  * Video
  46.  */
  47.  
  48. /* Video mode codes */
  49.  
  50. #define    VERTFLAG    0x100    /* double-line on VGA, interlace on ST/TV */
  51. #define    STMODES        0x080    /* ST compatible */
  52. #define    OVERSCAN    0x040    /* Multiply X&Y rez by 1.2, ignored on VGA */
  53. #define    PAL        0x020    /* PAL if set, else NTSC */
  54. #define    VGA        0x010    /* VGA if set, else TV mode */
  55. #define    COL80        0x008    /* 80 column if set, else 40 column */
  56. #define    NUMCOLS        7    /* Mask for number of bits per pixel */
  57. #define    BPS16        4
  58. #define    BPS8        3
  59. #define    BPS4        2
  60. #define    BPS2        1
  61. #define    BPS1        0
  62.  
  63. /* Montype return values */
  64. enum montypes {STmono=0, STcolor, VGAcolor, TVcolor};
  65.  
  66. /* VsetSync flags - 0=internal, 1=external */
  67.  
  68. #define    VID_CLOCK    1
  69. #define    VID_VSYNC    2
  70. #define    VID_HSYNC    4
  71.  
  72. #undef Setscreen
  73. #define Setscreen(lscrn,pscrn,rez,mode)                    \
  74.     (short)trap_14_wllww((short)5,(long)(lscrn),(long)(pscrn),    \
  75.         (short)(rez),(short)(mode))
  76. #define Vsetmode(mode)                            \
  77.     (short)trap_14_ww((short)88,(short)(mode))
  78. #define Montype()                            \
  79.     (short)trap_14_w((short)89)
  80. #define    VgetSize(mode)                            \
  81.     (long)trap_14_ww((short)91,(short)(mode))
  82. #define    VsetSync(ext)                            \
  83.     (void)trap_14_ww((short)90,(short)(ext))
  84. #define VsetRGB(index,count,array)                    \
  85.     (void)trap_14_wwwl((short)93,(short)(index),(short)(count),    \
  86.         (long *)(array))
  87. #define VgetRGB(index,count,array)                    \
  88.     (void)trap_14_wwwl((short)94,(short)(index),(short)(count),    \
  89.         (long *)(array))
  90. #define VsetMask(andmask,ormask)                    \
  91.     (void)trap_14_www((short)150,(short)(andmask),(short)(ormask))
  92.  
  93. /*
  94.  * Sound
  95.  */
  96.  
  97. /* _SND cookie values */
  98.  
  99. #define SND_PSG        0x01    /* Yamaha PSG */
  100. #define    SND_8BIT    0x02    /* 8 bit DMA stereo */
  101. #define    SND_16BIT    0x04    /* 16 bit CODEC */
  102. #define    SND_DSP        0x08    /* DSP */
  103. #define    SND_MATRIX    0x10    /* Connection Matrix */
  104.  
  105. /* XXX Docs say Falcon shows 0x3f. What does bit 0x20 mean ??? */
  106.  
  107. /*
  108.  * Sound data memory layout - samples are all signed values
  109.  *
  110.  *                 (each char = 1 byte, 2 chars = 1 word)
  111.  * 1 16 bit stereo track:    LLRRLLRRLLRRLLRR
  112.  * 1 8 bit stereo track:    LRLRLRLR  
  113.  * 2 16 bit stereo tracks:    L0R0L1R1L0R0L1R1
  114.  *  etc...
  115.  */
  116.  
  117. /* Setbuffer regions */
  118.  
  119. #define    SR_PLAY        0    /* Set playback registers */
  120. #define    SR_RECORD    1    /* Set record registers */
  121.  
  122. /* Soundcmd Modes */
  123.  
  124. #define LTATTEN        0    /* Left-channel output attenuation */
  125. #define    RTATTEN        1    /* Right channel atten */
  126. #define    LTGAIN        2    /* Left input gain */
  127. #define    RTGAIN        3    /* Right channel gain */
  128.     /* gain and attenuation in 1.5db units, 0x00V0, V:0-15 */
  129. #define    ADDERIN        4    /* Select inputs to adder 0=off, 1=on */
  130. #define    ADCIN        1    /* Input from ADC */
  131. #define    MATIN        2    /* Input from connection matrix */
  132. #define    ADCINPUT    5    /* Select input to ADC, 0=mic, 1=PSG */
  133. #define    ADCRT        1    /* Right channel input */
  134. #define    ADCLT        2    /* Left input */
  135. #define    SETPRESCALE    6    /* Set TT compatibility prescaler */
  136. #define    PREMUTE        0    /* was /1280, now is invalid, mutes */
  137. #define    PRE1280        PREMUTE
  138. #define    PRE640        1    /* divide by 640 */
  139. #define    PRE320        2    /* / 320 */
  140. #define    PRE160        3    /* / 160 */
  141.  
  142. /* Record/Playback modes */
  143.  
  144. #define    STEREO8        0    /* 8 bit stereo */
  145. #define    STEREO16    1    /* 16 bit stereo */
  146. #define    MONO8        2    /* 8 bit mono */
  147.  
  148. /* Record/Playback tracks range from 0 to 3 */
  149.  
  150. /* XXX Doc for Settracks could be clearer. Can we individually set, e.g.,
  151.    tracks 0 & 2 for playback, or must track selections be contiguous? */
  152.  
  153. /* Sound buffer interrupts */
  154.     /* sources */
  155. #define    SI_TIMERA    0    /* Timer A interrupt */
  156. #define    SI_MFPI7    1    /* MFP interrupt 7 */
  157.     /* causes */
  158. #define    SI_NONE        0    /* No interrupts */
  159. #define    SI_PLAY        1    /* Intr at end of play buffer */
  160. #define    SI_RECORD    2    /* Intr at end of record buffer */
  161. #define    SI_BOTH        3    /* Interrupt for either play or record */
  162.  
  163. /* Buffoper flags */
  164.  
  165. #define    SB_PLA_ENA    1    /* Play enable */
  166. #define    SB_PLA_RPT    2    /* Play repeat (continuous loop mode) */
  167. #define    SB_REC_ENA    4    /* Record enable */
  168. #define SB_REC_RPT    8    /* Record repeat */
  169.  
  170. /* Dsptristate - 0=tristate, 1=enable */
  171.  
  172. /* Gpio modes */
  173.  
  174. #define    GPIO_SET    0    /* Set I/O direction, 0=in, 1=out */
  175. #define    GPIO_READ    1    /* Read bits - only 3 bits on gpio */
  176. #define    GPIO_WRITE    2    /* Write gpio data bits */
  177.  
  178. /* Devconnect (connection matrix) source devices */
  179.  
  180. #define    DMAPLAY        0    /* DMA playback */
  181. #define    DSPXMIT        1    /* DSP transmit */
  182. #define    EXTINP        2    /* External input */
  183. #define    ADC        3    /* Microphone/PSG, see Soundcmd(ADCINPUT) */
  184.  
  185. /* Devconnect destination devices, bitmapped */
  186.  
  187. #define    DMAREC        1    /* DMA record */
  188. #define    DSPRECV        2    /* DSP receive */
  189. #define    EXTOUT        4    /* External output */
  190. #define    DAC        8    /* Headphone, internal speaker, monitor */
  191.  
  192. /* Devconnect clock sources */
  193.  
  194. #define    CLK25M        0    /* Internal 25.175 MHz clock */
  195. #define    CLKEXT        1    /* External clock */
  196. #define    CLK32M        2    /* Internal 32 MHz. Invalid for CODEC */
  197.  
  198. /* Devconnect clock prescaler values */
  199.  
  200. /* XXX Doc lists incorrect hz numbers for many of these... */
  201.  
  202. #define CLKOLD        0    /* TT compatible, see Soundcmd(SETPRESCALE) */
  203. #define    CLK50K        1    /* 49170 hz */
  204. #define    CLK33K        2    /* 32780 hz */
  205. #define    CLK25K        3    /* 24585 hz */
  206. #define    CLK20K        4    /* 19668 hz */
  207. #define    CLK16K        5    /* 16390 hz */
  208.         /*    6    (14049 hz) invalid for CODEC */
  209. #define    CLK12K        7    /* 12292 hz */
  210.         /*    8    (10927 hz) invalid for CODEC */
  211. #define    CLK10K        9    /* 9834 hz */
  212.         /*    10    (8940 hz) invalid for CODEC */
  213. #define    CLK8K        11    /* 8195 hz */
  214.         /*    12    (7565 hz) invalid */
  215.         /*    13    (7024 hz) invalid */
  216.         /*    14    (6556 hz) invalid */
  217.         /*    15    (6146 hz) invalid */
  218.  
  219. /* Sndstatus command */
  220.  
  221. #define    SND_CHECK    0    /* Check current status */
  222. #define    SND_RESET    1    /* Reset sound system */
  223.     /*
  224.      * Reset effects: DSP tristated, gain=atten=0, matrix reset,
  225.      * ADDERIN=0, Mode=STEREO8, Play=Record=Monitor tracks=0,
  226.      * interrupts disabled, buffer operation disabled.
  227.      */
  228.  
  229. /* Sndstatus status return */
  230.  
  231. #define    SS_OK        0    /* No errors */
  232. #define    SS_CTRL        1    /* Invalid control field (Data assumed OK) */
  233. #define    SS_SYNC        2    /* Invalid sync format (mutes) */
  234. #define    SS_SCLK        3    /* Serial clock out of valid range (mutes) */
  235.  
  236. #define    SS_RTCLIP    0x10    /* Right channel is clipping */
  237. #define    SS_LTCLIP    0x20    /* Left channel is clipping */
  238.  
  239. /* Structure used by Buffptr */
  240.  
  241. typedef struct SndBufPtr {
  242.     char *play;
  243.     char *record;
  244.     long reserve1;
  245.     long reserve2;
  246. } SndBufPtr;
  247.  
  248. #define Locksnd()                            \
  249.     (long)trap_14_w((short)128)
  250. #define Unlocksnd()                            \
  251.     (long)trap_14_w((short)129)
  252. #define Setbuffer(region,beg,end)                    \
  253.     (long)trap_14_wwll((short)131,(short)(region),(long)(beg),(long)(end))
  254. #define Soundcmd(mode,data)                        \
  255.     (long)trap_14_www((short)130,(short)(mode),(short)(data))
  256. #define Setmode(stereo_mode)                        \
  257.     (long)trap_14_ww((short)132,(short)(stereo_mode))
  258. #define Settracks(play,rec)                        \
  259.     (long)trap_14_www((short)133,(short)(play),(short)(rec))
  260. #define Setmontracks(montrack)                        \
  261.     (long)trap_14_ww((short)134,(short)(montrack))
  262. #define Setinterrupt(src_inter,cause)                    \
  263.     (long)trap_14_www((short)135,(short)(src_inter),        \
  264.         (short)(cause))
  265. #define Buffoper(mode)                            \
  266.     (long)trap_14_ww((short)136,(short)(mode))
  267. #define Dsptristate(dspxmit,dsprec)                    \
  268.     (long)trap_14_www((short)137,(short)(dspxmit),            \
  269.         (short)(dsprec))
  270. #define Gpio(mode,data)                            \
  271.     (long)trap_14_www((short)138,(short)(mode),(short)(data))
  272. #define Devconnect(src,dst,sclk,pre,proto)                \
  273.     (long)trap_14_wwwwww((short)139,(short)(src),(short)(dst),    \
  274.         (short)(sclk),(short)(pre),(short)(proto))
  275. #define Sndstatus(reset)                        \
  276.     (long)trap_14_ww((short)140,(short)(reset))
  277. #define Buffptr(ptr)                            \
  278.     (long)trap_14_wl((short)141,(long)(ptr))
  279.  
  280. /*
  281.  * DSP functions
  282.  *
  283.  * Don't even *think* of trying to use these without the manual!
  284.  */
  285.         
  286. #define    Dsp_DoBlock(data_in,size_in,data_out,size_out)            \
  287.     (void)trap_14_wllll((short)96,(long)(data_in),(long)(size_in),    \
  288.         (long)(data_out),(long)(size_out))
  289. #define    Dsp_BlkHandShake(data_in,size_in,data_out,size_out)        \
  290.     (void)trap_14_wllll((short)97,(long)(data_in),(long)(size_in),    \
  291.         (long)(data_out),(long)(size_out))
  292. #define    Dsp_BlkUnpacked(data_in,size_in,data_out,size_out)        \
  293.     (void)trap_14_wllll((short)98,(long)(data_in),(long)(size_in),    \
  294.         (long)(data_out),(long)(size_out))
  295. #define    Dsp_BlkWords(data_in,size_in,data_out,size_out)            \
  296.     (void)trap_14_wllll((short)123,(long)(data_in),(long)(size_in),    \
  297.         (long)(data_out),(long)(size_out))
  298. #define    Dsp_BlkBytes(data_in,size_in,data_out,size_out)            \
  299.     (void)trap_14_wllll((short)124,(long)(data_in),(long)(size_in),    \
  300.         (long)(data_out),(long)(size_out))
  301. #define    Dsp_MultBlocks(numsend,numrecv,sendblks,recvblks)        \
  302.     (void)trap_14_wllll((short)127,(long)(numsend),(long)(numrecv),    \
  303.         (long)(sendblks),(long)(recvblks))
  304. #define    Dsp_InStream(data_in,blksiz,numblks,blksdone)            \
  305.     (void)trap_14_wllll((short)99,(long)(data_in),(long)(blksiz),    \
  306.         (long)(numblks),(long)(blksdone))
  307. #define    Dsp_OutStream(data_out,blksiz,numblks,blksdone)            \
  308.     (void)trap_14_wllll((short)100,(long)(data_out),(long)(blksiz),    \
  309.         (long)(numblks),(long)(blksdone))
  310. #define    Dsp_IOStream(data_in,data_out,blkisiz,blkosiz,numblks,blksdone)    \
  311.     (void)trap_14_wllllll((short)101,(long)(data_in),(long)(data_out),\
  312.         (long)(blkisiz),(long)(blkosiz),(long)(numblks),    \
  313.         (long)(blksdone))
  314. #define    Dsp_SetVectors(rcvr,xmtr)                    \
  315.     (void)trap_14_wll((short)126,(long)(rcvr),(long)(xmtr))
  316. #define    Dsp_RemoveInterrupts(mask)                    \
  317.     (void)trap_14_ww((short)102,(short)(mask))
  318. #define    Dsp_GetWordSize()    (long)trap_14_w((short)103)
  319. #define    Dsp_Lock()        (long)trap_14_w((short)104)
  320. #define    Dsp_Unlock()        (void)trap_14_w((short)105)
  321. #define    Dsp_Available(xmem,ymem)                    \
  322.     (void)trap_14_wll((short)106,(long)(xmem),(long)(ymem))
  323. #define    Dsp_Reserve(xmem,ymem)                        \
  324.     (void)trap_14_wll((short)107,(long)(xmem),(long)(ymem))
  325. #define    Dsp_LoadProg(file,ability,buffer)                \
  326.     (long)trap_14_wlwl((short)108,(long)(file),(short)(ability),    \
  327.         (long)(buffer))
  328. #define    Dsp_ExecProg(codeptr,codesiz,ability)                \
  329.     (void)trap_14_wllw((short)109,(long)(codeptr),(long)(codesiz),    \
  330.         (short)(ability))
  331. #define    Dsp_ExecBoot(codeptr,codesiz,ability)                \
  332.     (void)trap_14_wllw((short)110,(long)(codeptr),(long)(codesiz),    \
  333.         (short)(ability))
  334. #define    Dsp_LodToBinary(file,codeptr)                    \
  335.     (long)trap_14_wll((short)111,(long)(file),(long)(codeptr))
  336. #define    Dsp_TriggerHC(vector)                        \
  337.     (void)trap_14_ww((short)112,(short)(vector))
  338. #define    Dsp_RequestUniqueAbility()    (long)trap_14_w((short)113)
  339. #define    Dsp_GetProgAbility()        (long)trap_14_w((short)114)
  340. #define    Dsp_FlushSubroutines()        (void)trap_14_w((short)115)
  341. #define    Dsp_LoadSubroutine(ptr,siz,ability)                \
  342.     (long)trap_14_wllw((short)116,(long)(ptr),(long)(siz),        \
  343.         (short)(ability))
  344. #define    Dsp_InqSubrAbility(ability)                    \
  345.     (long)trap_14_ww((short)117,(short)(ability))
  346. #define    Dsp_RunSubroutine(handle)                    \
  347.     (long)trap_14_ww((short)118,(short)(handle))
  348. #define    Dsp_Hf0(flag)                            \
  349.     (long)trap_14_ww((short)119,(short)(flag))
  350. #define    Dsp_Hf1(flag)                            \
  351.     (long)trap_14_ww((short)120,(short)(flag))
  352. #define    Dsp_Hf2()        (long)trap_14_w((short)121)
  353. #define    Dsp_Hf3()        (long)trap_14_w((short)122)
  354. #define    Dsp_HStat()        (char)trap_14_w((short)125)
  355.  
  356. #endif /* _FALCON_H */
  357.